feat: align protocol version reporting with init#778
Merged
Baskarayelu merged 4 commits intoQuickLendX:mainfrom Apr 1, 2026
Merged
feat: align protocol version reporting with init#778Baskarayelu merged 4 commits intoQuickLendX:mainfrom
Baskarayelu merged 4 commits intoQuickLendX:mainfrom
Conversation
- Add PROTOCOL_VERSION constant (= 1) and PROTOCOL_VERSION_KEY storage key to init.rs - Store PROTOCOL_VERSION in instance storage during initialize_internal so get_version always reflects the version active at init time - Add ProtocolInitializer::get_version() query method that reads from storage, falling back to the constant before init - Update lib.rs get_version to delegate to ProtocolInitializer::get_version instead of hardcoding 1u32 - Add 5 version-consistency tests in test_init.rs (before/after init, storage read, consistency, idempotent re-init) - Document get_version API and upgrade policy in docs/contracts/initialization.md Closes QuickLendX#725
…no_std WASM build
|
@Marvy247 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the inconsistency where
get_versionhardcoded1u32instead of reading the version stored during initialization.Also fixes a pre-existing WASM build failure in
verification.rswherestd::vec::Vecandstd::str::from_utf8were used in ano_stdcontext.Changes
init.rs— AddedPROTOCOL_VERSIONconstant (= 1) andPROTOCOL_VERSION_KEYstorage key. Version is written to instance storage duringinitialize_internal. AddedProtocolInitializer::get_version()that reads from storage, falling back to the constant before init.lib.rs—get_versionnow delegates toProtocolInitializer::get_versioninstead of hardcoding1u32.test_init.rs— 5 new version-consistency tests covering: before-init fallback, after-init match, direct storage read, before/after consistency, and idempotent re-init stability.docs/contracts/initialization.md— Documentedget_versionAPI and upgrade policy (patch/minor/major).verification.rs— Replacedstd::vec::Vec/std::str::from_utf8with a fixed-size stack array andcore::str::from_utf8to fix thewasm32v1-nonerelease build.Security Notes
get_versionis read-only — no new attack surface.Testing
cargo check --lib— clean (zero new errors)cargo build --target wasm32v1-none --release— now passesCloses #725